package com.four.peoplemanage.exit.controller;

import com.four.peoplemanage.common.bean.ResponseData;
import com.four.peoplemanage.common.controller.BaseController;
import com.four.peoplemanage.exit.entity.Exit;
import com.four.peoplemanage.exit.service.ExitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/exit")
public class ExitController extends BaseController {
    @Autowired
    ExitService exitService;
    //申请加班
    @PostMapping("/insert")
    public ResponseData<Boolean> insertExit(Exit exit){
        return returnBoolean(exitService.insert(exit));
    }

    //分页
    @GetMapping("/getAll")
    public ResponseData<Object>  getAll(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "name",required = false) String name,
            @RequestParam(value = "persionstatus",required = false) String persionstatus,
            @RequestParam(value = "office",required = false) String office,
            @RequestParam(value = "status",required = false) String status


    ){
        return returnObject(exitService.getPageExit(pageNum, pageSize, name, persionstatus,office,status));
    }
    //分页
    @GetMapping("/getone")
    public ResponseData<Object>  getOne(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "name",required = false) String name,
            @RequestParam(value = "persionstatus",required = false) String persionstatus,
            @RequestParam(value = "office",required = false) String office,
            @RequestParam(value = "status",required = false) String status,
            @RequestParam(value = "information_id",required = false) int information_id


    ){
        return returnObject(exitService.getOneExit(pageNum, pageSize, name, persionstatus,office,information_id,status));
    }

    //更新状态可撤销
    @PutMapping("/updateS")
    public  ResponseData<Boolean> updateS(@RequestBody Exit exit){
        return returnBoolean(exitService.updateStatus(exit));
    }
    //通过
    @PutMapping("/receive")
    public  ResponseData<Boolean> receive(@RequestBody Exit exit){
        return returnBoolean(exitService.updateSuccess(exit));
    }
    //驳回
    @PutMapping("/reject")
    public  ResponseData<Boolean> reject(@RequestBody Exit exit){
        return returnBoolean(exitService.updateFail(exit));
    }

    //编辑
    @PutMapping("/update")
    public ResponseData<Boolean> update(@RequestBody Exit exit){
        return returnBoolean(exitService.updateOvertime(exit));
    }
}
